﻿Public Class frmFacturesReglees
    Public pNoVersement As Integer
    Public pMontant As Decimal

    Private szSQL As String
    Private rs As ADODB.Recordset


    Private Sub frmFacturesReglees_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Me.Text = "VERSEMENT NO : " & pNoVersement
         Call InitReglements(0)
    End Sub


    Private Sub InitReglements(ByVal ix As Integer)

        Dim nb As Integer = 0
        Dim mtregle As Decimal

        ' effacer la listview
        LV_DOSSIERS.Items.Clear()

        ' lire toutes les réglements de la facture
        szSQL = "CALL spGET_FACTURE_REG_byBanque('" & gSocieteCode & "'," & pNoVersement & ")"
        GetRecordset(ctDSN_DEVFAC, szSQL, rs)
        Do While Not rs.EOF
            LV_DOSSIERS.Items.Add(rs.Fields("date").Value)
            LV_DOSSIERS.Items(nb).SubItems.Add(Format(rs.Fields("nofact").Value, "000000"))
            LV_DOSSIERS.Items(nb).SubItems.Add(rs.Fields("c_nom").Value)
            LV_DOSSIERS.Items(nb).SubItems.Add(rs.Fields("totalttc").Value)
            LV_DOSSIERS.Items(nb).SubItems.Add(rs.Fields("montant").Value)
            mtregle += rs.Fields("montant").Value
            rs.MoveNext()
            nb = nb + 1
        Loop
        rs.Close()

        TE_TOTALTTC.Text = pMontant.ToString("C")
        TE_DEJAREGLE.Text = mtregle.ToString("C")
        mtregle = pMontant - mtregle
        TE_RESTEREGLE.Text = mtregle.ToString("C")

        ' restaurer la position du curseur avant le init
        setIndice(ix, LV_DOSSIERS)

    End Sub


End Class